<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">

        <!-- <com-a v-if="judge"></com-a>
        <com-b v-else></com-b> -->
        <div :is="comname"></div>
        <!-- <button @click="judge=!judge">点击</button> -->
        <button @click="changeCom">点击</button>
    </div>
    <template id="coma">
        <h1>我是coma组件</h1>
    </template>
    <template id="comb">
        <h2>我是comb组件</h2>
    </template>
    <script>
        let ComA = {
            template:"#coma"
        }

        let ComB = {
            template:"#comb"
        }

        new Vue({
            el:"#app",
            components:{
                ComA,
                ComB
            },
            data:{
                message:"数据",
                judge:true,
                comname:"com-a"
            },
            methods:{
                changeCom(){
                    if(this.comname=="com-a"){
                        this.comname = "com-b";
                    }else{
                        this.comname = "com-a"
                    }
                    console.log(this.comname);
                }
            }
        })


    </script>
</body>
</html>